/**
 * StarInfoFrameExploredBase.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.backdrop.SolidBackdrop;
import com.ardor3d.extension.ui.layout.AnchorLayout;
import com.ardor3d.extension.ui.layout.AnchorLayoutData;
import com.ardor3d.extension.ui.util.Alignment;
import com.roslan.games.moo3d.GameData;
import com.roslan.games.moo3d.data.Star;
import com.roslan.games.moo3d.data.Star.Environment;
import com.roslan.games.moo3d.spatial.StarNode;

/**
 * Comments go here.
 * 
 * @author Roslan Amir
 * @version 1.0 - Jan 10, 2011
 */
public abstract class StarInfoFrameExploredBase extends StarInfoFrameBase {

	/**
	 * 
	 */
	protected final UILabel environmentValueLabel;

	/**
	 * 
	 */
	protected final UILabel specialsValueLabel;

	/**
	 * 
	 */
	protected final UILabel maxPopValueLabel;

	/**
	 * Constructor.
	 * 
	 * @param title - the title of the frame
	 */
	public StarInfoFrameExploredBase(String title) {
		super(title, new SolidBackdrop(GameData.COLOR_CHOCOLATE));

		final UIPanel panel = new UIPanel();
		panel.setLayout(new AnchorLayout());
		panel.setMargin(HudManager.MARGINS_ZERO);
		panel.setPadding(HudManager.PADDING_2000);
		panel.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel);

//		final UILabel environmentNameLabel = new UILabel("[b]Environment:[/b]");
		final UILabel environmentNameLabel = new UILabel("Environment:");
		environmentNameLabel.setStyledText(true);
		environmentNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 4, -6));
		panel.add(environmentNameLabel);

		environmentValueLabel = new UILabel("");
		environmentValueLabel.setStyledText(true);
		environmentValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 105, -6));
		panel.add(environmentValueLabel);

//		final UILabel specialsNameLabel = new UILabel("[b]Specials:[/b]");
		final UILabel specialsNameLabel = new UILabel("Specials:");
		specialsNameLabel.setStyledText(true);
		specialsNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 4, -24));
		panel.add(specialsNameLabel);

		specialsValueLabel = new UILabel("");
		specialsValueLabel.setStyledText(true);
		specialsValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 105, -24));
		panel.add(specialsValueLabel);

//		final UILabel maxPopNameLabel = new UILabel("[b]Max Pop:[/b]");
		final UILabel maxPopNameLabel = new UILabel("Max Pop:");
		maxPopNameLabel.setStyledText(true);
		maxPopNameLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 4, -42));
		panel.add(maxPopNameLabel);

		maxPopValueLabel = new UILabel("");
		maxPopValueLabel.setStyledText(true);
		maxPopValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 105, -42));
		panel.add(maxPopValueLabel);
	}

	/**
	 * Update the information to the currently selected Star (or Colony).
	 * 
	 * @param starNode - the Star (or Colony) whose info is to be upadated
	 */
	@Override
	public void update(StarNode starNode) {
		this.setTitle(starNode.getName() + " (" + starNode.tile.x + ',' + starNode.tile.y + ')');
		Star star = starNode.getStar();
		if ((star.environment != Environment.NONE)) {
			String color = (star.environment.ordinal() >= Environment.MINIMAL.ordinal()) ? "[c=#0a3]" : "[c=#a00]";
//			environmentValueLabel.setText("[b]" + color + star.environment.toString() + "[/c][/b]");
//			specialsValueLabel.setText("[b][c=#00a]" + star.specials + "[/c][/b]");
//			maxPopValueLabel.setText("[b][c=#00a]" + star.planetSize + "[/c][/b]");
			environmentValueLabel.setText(color + star.environment.toString() + "[/c]");
			specialsValueLabel.setText("[c=#00a]" + star.specials + "[/c]");
			maxPopValueLabel.setText("[c=#00a]" + star.planetSize + "[/c]");
		} else {
			environmentValueLabel.setText("");
			specialsValueLabel.setText("");
			maxPopValueLabel.setText("");
		}
	}

}
